#pragma once


#include <thread>

#include "../asio/include/asio.hpp"
#include "../asio/include/asio/ip/tcp.hpp"
#include "Client.h"

class NetServer
{
	typedef std::shared_ptr<clientSession> session_ptr;
public:
	NetServer(asio::io_service& ioservice, const tcp::endpoint& endpoint, HWND MainHwnd);
	const tcp::endpoint& GetEndPoint();
protected:
	void handle_accept(const asio::error_code& error, session_ptr& session);	
public:	
	bool IsServiceRuning();
	bool RunService(USHORT port);
	void stop();
private:
	bool m_bIsRun=false;
	HWND m_MainHwnd=nullptr;
	std::thread m_thrd;
	asio::io_service& m_ioservice;
	tcp::endpoint m_endPoint;
	tcp::acceptor m_acceptor;
};

